<template>
  <div>
    <el-row :gutter="10">
      <el-col :span="4">
        <!-- 树形结构 -->
        <componentsJgs  @node-click="itemClick"  />
      </el-col>
      <el-col :span="20">

        <div style="padding:10px 10px;background-color: white">
          <el-select v-model="AS0119" placeholder="请选择" style="margin-bottom: 10px">
            <el-option
              v-for="item in a0163s"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
          <el-input
            v-model="searchName"
            placeholder="请输入姓名或身份证号"
            style="width: 200px"
            @input="filter($event)"
          />

          <el-select v-model="findType" placeholder="人选类别查询">
            <el-option
              v-for="item in itemCodeList.SD16"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>

          <el-select style="width: 130px" v-model="jqgzPyql"  placeholder="成熟度">
            <el-option
              v-for="item in jqgzPyqls"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>

          <el-button icon="el-icon-search" type="primary" plain @click="query">
            查询
          </el-button>
          <el-button type="primary" plain icon="el-icon-search" @click="showSearchs">精确查询</el-button>
          <br/>
          <el-button type="primary" plain icon="el-icon-s-marketing" @click="wareHousingOpen" v-if="boolea == 'true'">入库</el-button>
          <el-button type="primary" plain icon="el-icon-s-release" @click="personOut" v-if="boolea == 'true'">出库</el-button>
          <el-button type="primary" plain icon="el-icon-star-on" @click="collect">收藏</el-button>

          <el-button type="primary" plain icon="el-icon-document-copy" v-if="boolea == 'true'" @click="updatePersonList">批量维护</el-button>

          <el-button type="primary" plain icon="el-icon-edit" @click="updatePersonInfo">xlsx导出字段</el-button>
          <el-button type="primary" plain icon="el-icon-download" @click="downloadPersonList">导出列表</el-button>
          <el-button type="primary" plain icon="el-icon-download" @click="openCollectionFile">采集信息导入</el-button>
          <el-badge :value="overAgeCount" style="margin:0px 6px" v-if="boolea == 'true'">
            <el-button type="primary" plain icon="el-icon-time" @click="checkOverAge">超龄</el-button>
          </el-badge>
          <el-button type="primary" plain icon="el-icon-document-delete" @click="openPerson">变动/异常提醒</el-button>
          <!-- <el-button type="primary" plain icon="el-icon-setting" @click="settingFixed">表格列设置</el-button> -->
          <el-button type="primary" plain icon="el-icon-s-order" @click="statisticsInformationIndex" v-if="boolea == 'true'">库内统计</el-button>
          <el-button type="primary" plain icon="el-icon-refresh" @click="synchronization" v-if="synchronizationFlag">同步数据</el-button>
        </div>

        <vxe-table
          v-if="columnList.length>0"
          element-loading-text="数据加载中"
          v-loading="loading"
          ref="mytable"
          :height="heightY"
          :data="articlesData"
          :align="allAlign = 'left'"
          :resizable="true"
          style="width: 100%;margin-top: 10px"
          :column-config="{useKey: getRowKeys }"
          border
          highlight-current-row
          @current-change="selectChange"
          @checkbox-change="handleSelectionChange"
          @checkbox-all="handleAllSelectChang"
          @cell-dblclick="dbSelected"
          show-overflow
        >
          <vxe-column
            v-if="columnList.length>0"
            type="checkbox"
            :reserve-selection="true"
            width="60"
            fixed="left"
          />
          <vxe-column title="姓名" fixed="left" width="101" allAlign = 'left'>
             <template slot-scope="scope">
              <div @click="dbSelected(scope.row)" style="color:#0220bf;cursor:pointer;">{{scope.row.a0101}}</div>
             </template>
          </vxe-column>
          <vxe-column field="a0104a" title="性别"  width="60"></vxe-column>
          <vxe-column field="a0184" title="身份证号"  width="180"></vxe-column>
          <vxe-column field="a0117a" title="民族"  width="80"></vxe-column>
          <vxe-column field="a0192" title="工作单位及职务"  width="250"></vxe-column>
          <vxe-column field="a0134" title="参加工作时间" width="160"></vxe-column>
          <vxe-column field="qrzxlxx" title="院校系专业"  width="180"></vxe-column>
          <vxe-column field="a0191" title="任现职时间"  width="140"></vxe-column>
          <vxe-column field='a0140' title="入党时间" width="120">
          </vxe-column>
          <vxe-column field="a0111a" title="籍贯" width="90"></vxe-column>
          <vxe-column field="qrzxw" title="最高全日制学位" width="180"></vxe-column>
          <vxe-column field="qrzxwxx" title="院校系专业" width="180"></vxe-column>
          <vxe-column field='a0192f' title="工作单位及职务任职时间" width="220"></vxe-column>
          <vxe-column field="a0107" title="出生年月" width="100"></vxe-column>
          <vxe-column field="qrzxl" title="最高全日制学历" width="160"></vxe-column>
          <vxe-column field="a0114a" title="出生地" width="110"></vxe-column>
          <vxe-column field="zzxl" title="最高在职学历"  width="140"></vxe-column>
          <vxe-column field="zzxwxx" title="院校系专业"  width="180"></vxe-column>
          <vxe-column field="a0196" title="专业技术职务" width="140"></vxe-column>
          <vxe-column field="zzxw" title="最高在职学位" width="140"></vxe-column>
          <vxe-column field="zzxlxx" title="院校系专业" width="180"></vxe-column>
          <vxe-column field="a0122" title="专业技术类公务员任职资格" width="240"></vxe-column>
          <vxe-column field="a0288" title="任现职务层次时间" width="180"></vxe-column>
          <vxe-column field="a0221" title="现职务层次" width="120"></vxe-column>
          <vxe-column field="a0192e" title="现职务" width="80"></vxe-column>
          <vxe-column field="a0120" title="级别" width="90"></vxe-column>
          <vxe-column field="a0160" title="人员类别" width="100"></vxe-column>
          <vxe-column title="是否两年以上基层工作经历" width="240">
            <template slot-scope="scope">
              <span v-if="scope.row.a0197 === 0">否</span>
              <span v-else-if="scope.row.a0197 === 1">是</span>
            </template>
          </vxe-column>
          <vxe-column field="a0187a" title="专长" width="60"></vxe-column>
          <vxe-column field="a0165" title="管理类别" width="120"></vxe-column>
          <vxe-column field="a0121" title="编制类型" width="100"></vxe-column>
          <vxe-column title="公务员登记时间" field="a2949" width="160"></vxe-column>
          <vxe-column field="a0128" title="健康状况" width="100"></vxe-column>
          <vxe-column field="a0163" title="人员管理状态" width="140"></vxe-column>
          <vxe-column field="a0195" title="统计关系所在单位" width="180"></vxe-column>
        </vxe-table>
        <div class="row" style="background: #fff;">
          <div class="col-sm text-sm-left text-left3 pt-3">
            <vxe-pager
              background
              align="left"
              :current-page.sync="currentPage"
              :page-size.sync="perPage"
              :total="totalItems"
              :layouts="['PrevJump', 'PrevPage', 'JumpNumber', 'NextPage', 'NextJump', 'Sizes', 'FullJump', 'Total']"
              @page-change="handleSizeChange">
            </vxe-pager>
          </div>

          <div>
            <rmb-add v-if="showRMB" ref="rmb"  @addCallback="initData"/>
            <person-out v-if="showPersonOut" ref="personOut" @personout="initData"/>
            <update-person-type-change v-if="showUpdatePersonType" ref="updatePersonTypeChange" @personout="initData"/>
          </div>
        </div>
      </el-col>
    </el-row>

    <div>
      <search v-if="showSearch" ref="search" @reloadList="initData"/>
    </div>
    <div>
      <updatePersons v-if="showUpdatePerson" ref="updatePersons" @indexInitAdd="initData"/>
    </div>
    <div>
      <show-basicZwShow v-if="showBasicZwShow" ref="dialogBasicZw" @reloadZwlb="initItemZwlb"/>
    </div>
    <div>
      <collectionFile v-if="dialogCollectionFile" ref="collectionFileRef"/>
    </div>

    <div>
      <wareHousing v-if="showWareHousing" ref="wareHousing" @refreshCallback="closePersonRem"></wareHousing>
      <over-age v-if="showOverAge" ref="overAge" @refreshCallback="closePersonRem"/>
    </div>

    <div>
      <personRemind v-if="dialogVisiblePerson" ref="personRem" @refreshCallback="closePersonRem"></personRemind>
    </div>
    <div>
      <updatePersonInfoExexl v-if="showUpdatePersonInfoExexl" ref="updatePersonInfoExexl" @indexInitAdd="initData"/>
    </div>
    <div>
      <controlColumnConfig ref="ref_config" v-if="configFixedDialog" @callblack="initColumn"></controlColumnConfig>
    </div>
    <div>
      <statisticsInformation v-if="showStatisticsInformation" ref="statistics_Information" />
    </div>
    <div>
    </div>
  </div>
</template>
<script>


import {getColumnList} from '@/api/young/datacollect/controlColumnConfig/controlColumnConfig'
import controlColumnConfig from "@/views/young/datacollect/controlColumnConfig/index"
import userSearch from '@/views/young/system/userDepartment/userSearch'
import wareHousing from '@/views/young/datacollect/wareHousing'
import collectionFile from '@/views/young/datacollect/collectionFile'
import {personCHooseNew,personCHoose, getTreeLeafLazy, exportExeclForPersonList,synchronizationData} from '@/api/young/datacenter/person.js'
import {getUserById} from '@/api/young/system/userDepartment/userDepartment'
import rmb from '@/views/young/datacollect/rmbInfo/rmb'
import search from '@/views/young/datacollect/search'
import {getA01ByA0000, collectData,getKJQGZList} from '@/api/young/datacollect/rmbInfo/rmb'
import personOut from '@/views/young/datacollect/rmbInfo/personOut'
import updatePersonTypeChange from '@/views/young/datacollect/rmbInfo/updatePersonTypeList'
import updatePersons from '@/views/young/system/collect/updatePersonList'
import updatePersonInfoExexl from '@/views/young/system/collect/updatePersonInfoExcel'
import statisticsInformation from '@/views/young/statistics/statisticsInformation/index'
import store from '@/store'
import basicZwShow from '@/views/young/datacollect/cadrePortrayal/basicZw'
import {getItem} from '@/api/young/system/role/role'
import overAge from '@/views/young/datacollect/rmbInfo/overAge'
import personRemind from '@/views/young/datacollect/rmbInfo/personRemind'
import componentsJgs from "./componentsJgs.vue";
import {
  selectRmind,selectOveAgePerson,selectAgeConfigure,
  getPersonsCount, getUserType
} from '@/api/young/datacollect/rmbInfo/rmb'
import {getItemTreeNew} from "@/api/young/system/dictionary/dictionary";
/*import moment from '@/api/young/moment.js'*/
// import currentFocusCadre from '@/views/young/datacollect/currentFocusCadre'

export default {
  name: 'PersonList',
  metaInfo: {
    title: '人员部门'
  },
  components: {
    'controlColumnConfig':controlColumnConfig,
    // 'currentFocusCadre':currentFocusCadre,
    'personRemind': personRemind,
    'collectionFile': collectionFile,
    // eslint-disable-next-line vue/no-unused-components
    'user-search': userSearch,
    // eslint-disable-next-line vue/no-unused-components,no-undef
    'rmb-add': rmb,
    'person-out': personOut,
    'update-person-type-change': updatePersonTypeChange,
    'search': search,
    'updatePersons': updatePersons,
    'updatePersonInfoExexl': updatePersonInfoExexl,
    'statisticsInformation': statisticsInformation,
    'show-basicZwShow': basicZwShow,
    'wareHousing': wareHousing,
    'over-age': overAge,
    'componentsJgs':componentsJgs,
  },
  data: () => ({
    props: {
      label: 'name',
      children: 'zones',
      isLeaf: 'leaf',
      icon: ''
    },
    configFixedDialog:false,

      // showCurrentFocusCadre:false,

    dialogCollectionFile: false,
    overAgeCount: 0,
    personCount: 0,
    count:0,
    dialogVisiblePerson: false,
    showOverAge: false,
    loading: false,
    icon: '',
    itemList: [], // 权限字段
    showWareHousing: false,
    showBasicZwShow: false,
    showUpdatePerson: false,
    showUpdatePersonInfoExexl: false,
      showStatisticsInformation: false,
    isContain: true,
    valid: '',
    showUserSearch: true,
    heightTree: window.innerHeight - 220 + 'px',
    a0163: '1',
    personList: [],
    isCheck: false,
    A0184: '',
    showPersonOut: false,
    showUpdatePersonType: false,
    A0101: '',
    current: '',
    searchName: '',
    showRMB: false,
    showSearch: false,
    a0165: '',
    AS0119: '1',
    radioC: '1',
    searchType: '1',
    AS0101: '',  // 女干部
    AS0103: '', // 少数民族干部
    AS0104: '', // 党外干部
    a0163s: [{
      value: '1',
      label: '优秀年轻干部'
    }, {
      value: '2',
      label: '历史优秀年轻干部'
    }
    ],
    a0165s: [{
      value: '',
      label: '增加人员'
    }, {
      value: '01',
      label: '导入任免表'
    }, {
      value: '02',
      label: '批量导入任免表'
    }, {
      value: '03',
      label: '手工录入人员信息'
    }],
    selectWay: [{
      value: '1',
      label: '姓名查询'
    }, {
      value: '2',
      label: '身份证查询'
    }],
    selectedPerson: [],
    // 分页
    searchKeys: ['getintoId', 'roleName'],
    totalItems: 0,
    currentPage: 1,
    perPage: 20,
    articlesData: [],
    // 选中的树节点
    selectedNode: '',
    defaultProps: {
      id: 'id',
      children: 'children',
      label: 'text'
    },
    // 家庭成员信息（表单提交保存用）
    a36s: [{
      // 称谓
      relation: '',
      // 称谓描述
      relationdesc: '',
      // 姓名
      name: '',
      // 出生日期
      birthDate: '',
      // 政治面貌
      policitalStatus: '',
      // 政治面貌描述
      policitalStatusdesc: '',
      // 工作单位及职务
      jobPost: ''
    }],
    heightY: window.innerHeight - 275 + 'px',
    queryParams: [], // 接收精确查询的条件,
    mySwiper: null,
    activeName: 'zzjg',
    boolea: '',
    columnList: [],
    findType:null,
    jqgzPyql:'',
    jqgzPyqls:[
          {
              value: '',
              label: ''
          },
          {
              value: '1',
              label: '可近期关注'
          }, {
              value: '2',
              label: '有培养潜力'
          },
      ],
    isAlign : true,
    itemCodeList:{},
    multipleSelection:[],
    gird:"2",
    young:"2",
    nation:"2",
    outside:"2",
    returned:"2",
    dataListItem:{},
    dataA01List:{},
    getA88List:[],
    getA02List:[],
    dataData:[],
    isFirstQuery: true,
    listpersonlist:[],
    userType:"",
    synchronizationFlag:true,
  }),
  computed: {},
  mounted() {
    this.initColumn();
    this.initAdd();
  },
  methods: {
    synchronization(){//同步数据
      var that = this;
      const userParams = {
          'userId': JSON.parse(sessionStorage.getItem(`userInfo`)).userId
      }

      const getUserPromise = getUserById(userParams);
      Promise.all([getUserPromise]).then((values)=>{
        const date = values[0];
        if(date.result){
          that.userType = date.resultdata.userType
        }
      })

      if(that.userType == 3){//只有规划办账号登录时调用此接口
        this.synchronizationFlag = true;
        synchronizationData().then((result) =>{
          if(result.result) {
            that.$message({
              message: '正在进行后台同步',
              type: 'success'
            });
          }else{
            that.$message({
              message: '操作失败',
              type: 'success'
            });
          }
        })
      }else if(that.userType == 1 && that.userType == 2 && that.userType == 4){
        this.synchronizationFlag = false;
      }
    },
    getItemByCode(dataCode) {
      const params = {
        'dataCode': dataCode // 代码类型
      }
      getItemTreeNew(params).then((data) => {
        this.itemCodeList[`${dataCode}`] = []
        if (dataCode != "SD13") {
          this.itemCodeList[`${dataCode}`].push({
            'value': "",
            'label': ""
          })
        }
        data.resultdata.forEach((item) => {
          this.itemCodeList[`${dataCode}`].push({
            'value': item.itemCode,
            'label': item.itemName
          })
        })
      })
    },

    //初始化字段控制
    initColumn() {
      this.configFixedDialog=false;
      this.columnList=[];
      this.$nextTick(()=>{
        getColumnList().then(res => {
          if (res.result) {
              res.resultdata.forEach((item) => {
                  if(!item.columnAlign){
                     this. isAlign = "left"
                  }
              })
            this.columnList = res.resultdata;
          }
        });
      })

    },
    formatDate(value) {
      if (value) {
        let date = new Date(value);
        let Y = date.getFullYear() + '.';
        let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1)  : date.getMonth() + 1 ;
        let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
        return Y + M;
      }
      //return moment(date).format("YYYY-MM-DD")
    },
    settingFixed(){
      this.configFixedDialog=true;
      this.$nextTick(()=>{
          this.$refs.ref_config.init(this.columnList);
      })
    },
      statisticsInformationIndex(){
          this.showStatisticsInformation=true;
          this.$nextTick(() => {
              this.$refs.statistics_Information.init()
          })
      },


    filter(){},
    closePersonRem() {
      this.initAdd();
      this.query();
    },
    openPerson() {
      this.dialogVisiblePerson = true;
      this.$nextTick(() => {
        this.$refs.personRem.getPersonsInit(500, 'AS0119', 'young');
      })
    },
    checkOverAge() { // 查看
      this.showOverAge = true
      this.$nextTick(() => {
        this.$refs.overAge.init()
      })
    },
    loadNode(node, resolve) {
      let params
      if (node.level === 0) {
        // 获得parentId = -1 的树
        params = {
          'userId': store.getters.user_id.toString(),
          'parentId': '-1'
        }
      } else {
        params = {
          'userId': store.getters.user_id.toString(),
          'parentId': node.data.id
        }
      }
      getTreeLeafLazy(params).then((data) => {
        //return resolve(data.resultdata);
        data.resultdata.forEach((item) => {
          //let treeIcon = ''
          if (item.b0194 == '机构分组') {
            item.icon = 'customRoot-icon'
          } else if (item.b0194 == '内设机构') {
            item.icon = 'customChildren-icon'
          } else if (item.b0194 == '法人单位') {
            item.icon = 'customParent-icon'
          }
        })
        return resolve(data.resultdata)
      })
    },
    // 根据roleId 获取权限字段
    getJurisdictionItem() {
      const that = this
      getItem().then(function (result) {
        that.itemList = []
        if (result.result) {
          that.itemList = result.resultdata // 权限字段

        }
      })
    },
    async initAdd() {
      this.getItemByCode('SD16');
      var that = this
      // 当前登录人是否为超级管理员
      await getUserType().then(function (result) {
        that.boolea = result.resultdata[0]
      })
      let params = {
        'column': 'AS0119',
        'type': 'young'
      }
        if(that.boolea != 'false') {
            that.overAgeCount = 0;
            var that = this
            await selectAgeConfigure().then(function (result) {
                if (result.result) {
                    result.resultdata.forEach((item) => {
                        if (item.endDate != null) {
                            that.endDate = that.format(item.endDate)
                        } else {
                            that.endDate = null;
                        }
                        that.addYear = item.addYear
                        if (item.ag0140a == '副厅级') {
                            that.ftAge = item.age
                        } else if (item.ag0140a == '正处级') {
                            that.zcAge = item.age
                        } else if (item.ag0140a == '副处级') {
                            that.fcAge = item.age
                        } else if (item.ag0140a == '镇街党政正职') {
                            that.zjAge = item.age
                        }
                    })
                }
            });
            var param = {
                'ftAge': that.ftAge,
                'zcAge': that.zcAge,
                'fcAge': that.fcAge,
                'zjAge': that.zjAge,
                'endDate': that.endDate,
                'addYear': that.addYear,
                'page': this.currentPage,
                'rows': this.perPage,

            }
            await selectOveAgePerson(param).then(function (result) {
                if (result.result) {
                    //that.articlesData = result.resultdata
                    that.overAgeCount = result.resultdata[0].count
                }
            })
        }
      that.visible = true
    },
    selectChange(currentRow) {
      this.current = currentRow
    },


    getnodeico(data) {
      if (data.id === '1') {
        return 'el-icon-folder'
      } else {
        return 'el-icon-folder'
      }
    },
    handleSelectionChange(personRow) {
      this.personList = []
      this.multipleSelection = []
      this.personList = personRow.records;
    },
    handleAllSelectChang({ checked, records }){
      
      this.multipleSelection = []
      this.personList = []
       this.multipleSelection = records
    },
    wareHousingOpen() {//入库
      var that = this;
      that.showWareHousing = true;
      that.$nextTick(() => {
        that.$refs.wareHousing.init('young')
      })
    },
    personOut() { // 出库
      var that = this
      let dataList = this.personList.length || this.multipleSelection.length
      if (dataList == 0) {
        that.$message({
          message: '请选择人员',
          type: 'warning'
        })
        return
      }
      let listpersonlist=[...this.personList,...this.multipleSelection];
      if (dataList > 0) {
        listpersonlist.forEach((item) => {
          if (item.as0119 == '0') {
            that.$message({
              message: '选择中包含有已出库人员',
              type: 'warning'
            })
            that.showPersonOut = false
          } else {
            // 点击出库的时候 将勾选的人员进行判断 （女少非人员是没有出库的）
            that.showPersonOut = true
            that.$nextTick(() => {
              that.$refs.personOut.init(listpersonlist)
            })
          }
        })
      }
    },
    collect() {
      var that = this;
      let dataList = this.personList.length || this.multipleSelection.length
      if (dataList == 0) {
        that.$message({
          message: '请选择人员',
          type: 'warning'
        })
        return
      }
      let listpersonlist=[...this.personList,...this.multipleSelection];
      const params = {
        parentId:listpersonlist,
        userId: store.getters.user_id.toString(),
      }

      this.listpersonlist = listpersonlist;

      collectData(params).then(function (result) {
        if (result.result) {
          that.$message({
            message: '收藏成功',
            type: 'success'
          })
        } else {
          this.$message.error(result.message)
        }
      })
    },



    query() {
      if (!this.selectedNode) {
        this.$message({
          message: "请先选择机构",
          type: "warning",
        });
        return;
      }else {
        this.A0101 = null;
        this.A0184 = null;
        this.queryParams = [];
        var han = /^[\u4e00-\u9fa5]+$/;
        var cardId = /\d/g;
        var vals = this.searchName.trim(); //获取输入input中的val
        if (han.test(vals)) {
          //test()方法表示是否匹配，返回值为true 成功，false 匹配失败
          this.A0101 = this.searchName.trim();
          this.currentPage = 1;
        } else {
          if (cardId.test(vals)) {
            this.A0184 = this.searchName.trim();
            this.currentPage = 1;
          } else {
            this.A0101 = this.searchName.trim();
            this.currentPage = 1;
          }
        }
        this.initData();
      }
    },
    updatePersonList() {
      let dataList = this.personList.length || this.multipleSelection.length
      if (dataList == 0) { // 如果没有勾选数据，则弹出提示信息
        this.$message({
          message: '请先选择人员',
          type: 'warning'
        })
        return
      }else{
        this.showUpdatePerson = true
        
        // if (this.personList.length === 0) {
          this.$nextTick(() => {
            // 按照机构获取当前机构全部人员
            if (this.curOrgId != undefined) {
              var isContainStr = '1'
              if (!this.isContain) {
                isContainStr = '2'
              }
              let listpersonlist=[...this.personList,...this.multipleSelection];
              this.listpersonlist = listpersonlist
              this.$refs.updatePersons.initAdd(this.listpersonlist)

            } else {
              this.$message({
                type: 'warning',
                message: '请选择机构！'
              })
              return;
            }
          })
        // }
      }
    },
    getParent(id, modules) {
      const parentMenu = []
      modules.forEach((item) => {
        if (item.parentId === id) {
          const b0194 = item.b0194
          let treeIcon = ''
          if (b0194 == '3') {
            treeIcon = 'customRoot-icon'
          } else if (b0194 == '2') {
            treeIcon = 'customChildren-icon'
          } else if (b0194 == '1') {
            treeIcon = 'customParent-icon'
          }

          const node = {
            label: item.name,
            id: item.id,
            children: [],
            parentId: item.parentId,
            type: b0194,
            icon: treeIcon

          }
          parentMenu.push(node)
          this.getChildMenu(node, modules)
        }
      })
      return parentMenu
    },
    getChildMenu(node, modules) {
      const itemMenu = this.getParent(node.id, modules)
      node.children = itemMenu
      if (itemMenu.length > 0) {
        itemMenu.forEach((node) => {
          this.getChildMenu(node, modules)
        })
      }
    },
    checkIDCard(idcode) {
      // 加权因子
      var weight_factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
      // 校验码
      var check_code = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
      var code = idcode + ''
      var last = idcode[17]// 最后一位
      var seventeen = code.substring(0, 17)
      // ISO 7064:1983.MOD 11-2
      // 判断最后一位校验码是否正确
      var arr = seventeen.split('')
      var len = arr.length
      var num = 0
      for (var i = 0; i < len; i++) {
        num = num + arr[i] * weight_factor[i]
      }
      // 获取余数
      var resisue = num % 11
      var last_no = check_code[resisue]
      // 格式的正则
      // 正则思路
      /*
        第一位不可能是0
        第二位到第六位可以是0-9
        第七位到第十位是年份，所以七八位为19或者20
        十一位和十二位是月份，这两位是01-12之间的数值
        十三位和十四位是日期，是从01-31之间的数值
        十五，十六，十七都是数字0-9
        十八位可能是数字0-9，也可能是X
        */
      var idcard_patter = /^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0|1][0-9])([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/
      // 判断格式是否正确
      var format = idcard_patter.test(idcode)
      // 返回验证结果，校验码和格式同时正确才算是合法的身份证号码
      return !!(last === last_no && format)
    },
    handleSizeChange({currentPage, pageSize}) {
      this.currentPage = currentPage
      this.perPage = pageSize
      this.initData()
    },
    initData() {
      var params
        this.personList=[]
      if (this.queryParams.length != 0) {
        this.queryParams.page = this.currentPage
        this.queryParams.rows = this.perPage
        params = this.queryParams
      } else {
        var isContainStr = '1'
        if (!this.isContain) {
          isContainStr = '2'
        }
        params = {
          'userId': store.getters.user_id.toString(),
          'orgId': this.curOrgId,
          'page': this.currentPage,
          'rows': this.perPage,
          'isContain': isContainStr,
          'AS0119': this.AS0119,
          'radioC': this.radioC,
          'A0101': this.A0101,
          'A0184': this.A0184,
          'findType':this.findType,
            'jqgzPyql':this.jqgzPyql
        }
      }
      this.personChoose(params)
    },
    async initItemZwlb(data) {
      alert(data)
    },
    // 双击行数据
    dbSelected(row) {
      console.log(row,"row");
      let trow = row.row || row
      var that = this
      that.showRMB = true
        that.$nextTick(() => {
          that.showRMB = true
          that.$refs.rmb.init(trow, that.itemList)
        })
    },

    showSearchs() {
      var that = this
      that.showSearch = true

      that.$nextTick(() => {
        that.showSearch = true
        const params = {
          'AS0119': this.AS0119
        }
        that.$refs.search.initAdd(params)
      })
    },
    onSearchSuccess() {

    },
    searchUpdateData(val, value, params) {
      if (val != null && val != undefined && val != 'undefined') {
        this.totalItems = 0
        this.articlesData = []
        if (value == '1') {// 姓名身份证查询
          if (val.length > this.perPage) {   // 大于当前页面分页条数   进行分页查询
            params.page = this.currentPage
            params.rows = this.perPage
            this.personChoose(params)
          } else {
            this.totalItems = val.length // 设置总记录数
            this.articlesData = val // 填充列表数据
          }
          this.queryParams = params
        } else {    // 常用查询
          this.totalItems = parseInt(val.count) // 设置总记录数
          this.articlesData = val.list // 填充列表数据
          this.queryParams = params
        }
      }
    },
    itemClick(node) {
      console.log(node,"node");
      this.queryParams = []
      this.$refs.mytable.clearCheckboxRow();
      this.selectedNode = node
      this.showPersons(node)
      this.isFirstQuery = false;
    },
    personChoose(prams) {
      this.loading = true;
      personCHooseNew(prams).then(data => {
        if (data.result) {
          if (data.resultdata) {
            this.getJurisdictionItem()
            if (data.result) {
              this.totalItems = 0
              this.articlesData = []
              this.totalItems =parseInt(data.resultdata.count) // 设置总记录数
              this.articlesData = data.resultdata.list // 填充列表数据
              this.$nextTick(() => {
                this.$refs.mytable.recalculate()
              })
            } else {
              this.$message.error(item.message)
            }

          }
        } else {
          this.$message.error(data.message)
        }
        this.loading = false;
      })
    },

    async showPersons(node) {
      var orgId = node.id
      this.curOrgId = orgId
        this.A0101 = null;
        this.A0184 = null;
        this.queryParams = []
        var han = /^[\u4e00-\u9fa5]+$/;
        var cardId=/\d/g
        var vals=this.searchName.trim();//获取输入input中的val
        if(han.test(vals)){//test()方法表示是否匹配，返回值为true 成功，false 匹配失败
            this.A0101 = this.searchName.trim();
            this.currentPage = 1
        }else{
            if(cardId.test(vals)){
                this.A0184 = this.searchName.trim()
                this.currentPage = 1
            }else {
                this.A0101 = this.searchName.trim();
                this.currentPage = 1
            }
        }
      var iscontain = '1'
      if (!this.isContain) iscontain = '2'
      const personJsons = {
        'userId': store.getters.user_id.toString(),
        'orgId': orgId,
        'page': this.currentPage,
        'rows': this.perPage,
        'isContain': iscontain,
        'AS0119': this.AS0119,
        'A0101':this.A0101,//代表的是名字
        'A0184': this.A0184,//代表的是身份证号
        'findType':this.findType,
        'jqgzPyql':this.jqgzPyql
      }
      this.personChoose(personJsons)
    },

    openCollectionFile() {
      this.dialogCollectionFile = true;
      this.$nextTick(() => {
        this.$refs.collectionFileRef.init();
      })
    },
    updatePersonType() {
      var that = this
      // 变更
      that.showUpdatePersonType = true
        if (this.personList.length == 0) {
            this.$nextTick(() => {
                // 按照机构获取当前机构全部人员
                if (this.curOrgId != undefined) {
                    var isContainStr = '1'
                    if (!this.isContain) {
                        isContainStr = '2'
                    }
                    const personJsons = {
                        'userId': store.getters.user_id.toString(),
                        'orgId': this.curOrgId,
                        'batch': '1',
                        'isContain': isContainStr,
                        'AS0119': this.AS0119
                    }
                    personCHoose('/datacollect/person/querybyid', personJsons).then(data => {
                        if (data.result) {
                            if (data.resultdata) {
                                if (data.result) {
                                    const params = {
                                        'parentId': data.resultdata.list
                                    }
                                    this.$refs.updatePersonTypeChange.initAdd(params, "young",'1')
                                } else {
                                    this.$message.error(item.message)
                                }
                            }
                        } else {
                            this.$message.error(data.message)
                        }
                    })

                } else {
                    this.$message({
                        type: 'warning',
                        message: '请选择机构！'
                    })
                    return;
                }
            })
        } else {
            this.$nextTick(() => {
                const params = {
                    'parentId': this.personList
                }
                that.$refs.updatePersonTypeChange.initAdd(params, "young",'1')
            })
        }
    },
    downloadPersonList() {
      const params = {
        //   'personList': this.articlesData,
        'fileName': '人员管理信息列表.xlsx',
        'personList': this.$refs.mytable.selection,
        'userId': JSON.parse(sessionStorage.getItem(`userInfo`)).userId
      }
      if(this.$refs.mytable.selection.length == 0){
        this.$message({
          type:'warning',
          message:'未选中任何数据'
        })
      }
      exportExeclForPersonList(params).then(function (result) {
      })
    },
    /**
     * @getRowKeys 设置回显的函数
     * @parmas row 当前行的数据，需要一个唯一的标识来标记是哪一个被选中了
     */
    getRowKeys(row) {
      return row.a0000;
    },
    updatePersonInfo() {
      this.showUpdatePersonInfoExexl = true
      this.$nextTick(() => {
        this.$refs.updatePersonInfoExexl.initAdd()
      })
    },
      add0: function (m){return m<10?'0'+m:m },
      format: function (shijianchuo) {
          //shijianchuo是整数，否则要parseInt转换
          var time = new Date(shijianchuo);
          var y = time.getFullYear();
          var m = time.getMonth()+1;
          var d = time.getDate();
          return y+'-'+this.add0(m)+'-'+this.add0(d);
      },
  }
}
</script>

<style scoped>
.swiper-container {
  --swiper-theme-color: #ff6600; /* 设置Swiper风格 */
  --swiper-navigation-color: #909399; /* 单独设置按钮颜色 */
  --swiper-navigation-size: 15px; /* 设置按钮大小 */
}

.customRoot-icon {
  width: 20px;
  height: 16px;
  display: inline-block;
  background: url('../../../assets/images/young/customRoot.png') no-repeat;

}

.customParent-icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: url('../../../assets/images/young/customParent.png') no-repeat;
}

.customChildren-icon {
  width: 20px;
  height: 18px;
  display: inline-block;
  background: url('../../../assets/images/young/customChildren.png') no-repeat;
}


.icon {
  width: 1em;
  height: 1em;
  vertical-align: -0em;
  fill: currentColor;
  overflow: hidden;
}
>>>.vxe-header--column .vxe-cell--title{
    font-size: 18px;
    font-weight: normal;
    /* color:#909399; */
    font-family: '微软雅黑';
  }
  >>>.vxe-cell--label{
    font-size: 16px;
    font-family: '微软雅黑';
  }
  >>>.vxe-table--render-default .vxe-cell{
    font-size:16px;
    font-family: '微软雅黑';
  }
</style>
